package com.cc.controller;


import com.cc.service.UserService;
import com.dy.cc.User;
import com.kaoshi.common.config.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("findAll")
    public Result findAll(User user,Integer uid){
        List<User> userList = userService.findAll(user,uid);
        return Result.ok(userList);
    };

    @RequestMapping("findById")
    public Result find(Integer id){
        User byId = userService.findById(id);
        return Result.ok(byId);
    };



    @GetMapping("updateStatus")
    public Result update(Integer id) {
        // 假设通过 uid 获取用户信息
        User user = userService.findById(id);

        if (user == null) {
            return Result.fail("用户不存在");
        }
        user.setClearStatus(0);
        userService.updateById(user);
        return Result.ok("更新成功");
    }




}
